22. Lab: VGG, Inception (GoogLeNet) and ResNet

Transfer Learning with VGG, Inception (GoogLeNet) and ResNet

In this lab, you will continue exploring transfer learning. You've already explored feature extraction with AlexNet and TensorFlow. Next, you will use Keras to explore feature extraction with the VGG, Inception and ResNet architectures. The models you will use were trained for days or weeks on the ImageNet dataset. Thus, the weights encapsulate higher-level features learned from training on thousands of classes.

There are some notable differences from AlexNet lab.

  1. We're using two datasets. First, the German Traffic Sign dataset, and second, the Cifar10 dataset.
  2. Bottleneck Features. Unless you have a very powerful GPU, running feature extraction on these models will take a significant amount of time, as you might have observed in the AlexNet lab. To make things easier we've precomputed bottleneck features for each (network, dataset) pair. This will allow you to experiment with feature extraction even on a modest CPU. You can think of bottleneck features as feature extraction but with caching. Because the base network weights are frozen during feature extraction, the output for an image will always be the same. Thus, once the image has already been passed through the network, we can cache and reuse the output.
  3. Furthermore, we've limited each class in both training datasets to 100 examples. The idea here is to push feature extraction a bit further. It also greatly reduces the download size and speeds up training. The validation files remain the same.

The files are encoded as such:

  • {network}_{dataset}_100_bottleneck_features_train.p
  • {network}_{dataset}_bottleneck_features_validation.p

"network", in the above filenames, can be one of 'vgg', 'inception', or 'resnet'.

"dataset" can be either 'cifar10' or 'traffic'.

Getting Started

  1. Download one of the bottleneck feature packs. VGG is the smallest so you might want to give that a shot first. You can download these from the Supplement Materials at the bottom of this page.
  2. Clone the lab repository
git clone https://github.com/udacity/CarND-Transfer-Learning-Lab
cd CarND-Transfer-Learning-Lab
  1. Open feature_extraction.py in your favourite text editor. We'll go over the code next.